#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const int INF=0x3f3f3f3f;
int map[6][6];
vector<int> res_i;
vector<int> res_j;
bool vis[6][6];
int dfs(int i,int j){
    //printf("%d %d\n",i,j);
    if(i==4 && j==4){
        return 1;
    }
    if(vis[i][j] || map[i][j]==1){
        return INF;
    }
    vis[i][j]=true;
    int min_i=INF;
    int min_j=INF;
    int min_c=INF;
    if(!vis[i+1][j] && i+1>=0 && i+1<5){
        int ctmp=dfs(i+1,j);
        if(ctmp<min_c){
            min_c=ctmp;
            min_i=i+1;
            min_j=j;
        }
    }
    if(!vis[i][j+1] && j+1>=0 && j+1<5){
        int ctmp=dfs(i,j+1);
        if(ctmp<min_c){
            min_c=ctmp;
            min_i=i;
            min_j=j+1;
        }
    }
    if(min_c!=INF){
        res_i.push_back(min_i);
        res_j.push_back(min_j);
    }
    //printf("%d %d\n",min_i,min_j);
    return min_c;
}
int main(void){
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            scanf("%d",&map[i][j]);
        }
    }
    dfs(0,0);
    printf("(0, 0)\n");
    int len=res_i.size();
    for(int i=len-1;i>=0;i--){
        printf("(%d, %d)\n",res_i[i],res_j[i]);
    }
    return 0;
}
